home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Extension Shell 1.5 / Sample Extensions (1.5) / Shutdown Fade ƒ / Gamma.h < prev    next >
Text File  |  1994-01-26  |  5KB  |  118 lines

  1. /*    NAME:
  2.         Gamma.h
  3.  
  4.     WRITTEN BY:
  5.         Matt Slot
  6.                 
  7.     DESCRIPTION:
  8.         Header file from Matt Slot's Gamma Table library source code.
  9.  
  10.     ___________________________________________________________________________
  11. */
  12. #ifndef __GAMMA__
  13. #define __GAMMA__
  14. //=============================================================================
  15. // File "gamma.h" - Header for Altering the Gamma Tables of GDevices
  16.  
  17. // * ****************************************************************************** *
  18. //
  19. //    This library is intended as a general tool for manipulating the Gamma Tables
  20. //        of Graphics Devices, to ramp them up or down in order to achieve smooth
  21. //        screen fades. The source is included for programmers who want to convert
  22. //        the library to A4-based, but it is not commented for public consumption.
  23. //    The library defines 2 globals to save state data, but the entire Table 
  24. //        manipulation is performed with unlocked handles to be easy on your heap.
  25. //        The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit 
  26. //        depth, or about 1700 bytes for one in 24-bit color. Usage will vary.
  27. //    Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines
  28. //        with attached monitors. (I don't know about the Color Classic tho’!). Also,
  29. //        GDevice manipulation needs to follow InitGraf() & InitWindows() calls.
  30. //    Please use the listed functions to see if you can use this code before you set
  31. //        it up. As usual, this stuff is not warranteed, guaranteed, or anything--
  32. //        use it at your own risk. It is not Apple-recommended for anything, but it
  33. //        worked for me, so there!
  34. //    
  35. //        Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                
  36. //        
  37. //        Updated:     3/13/93, MJS                                                
  38. //                        •>    Updated the GammaAvail calls to be more honest.
  39. //                            Actually check to see if Grafix Devices are supported
  40. //                            on this machine w/o using Gestalt. Also, used the 
  41. //                            std. Toolbox calls to test the GDevice attributes.
  42. //                        •>    Removed extraneous calls to lock handles in several
  43. //                            locations.
  44. //                        •>    Fixed bug in DoOneGammaFade which failed if the device
  45. //                            could not be found in the list.
  46. //                        •>    Changed function prototypes to be more intuitive.
  47. //                        •>    Updated the descriptions in header file.
  48. //                        •>  Thanks to David Phillip Oster, oster@well.sf.ca.us,
  49. //                            for his numerous suggestions and criticisms. :)
  50. //    
  51. //        Oh yeah, this stuff is free to anyone interested in it.
  52. //
  53. // * ****************************************************************************** *
  54.  
  55. //    A quick signature
  56. #define kGammaUtilsSig    'GAMA'
  57.  
  58. //    To help check for compatibility
  59. #define kGetDeviceListTrapNum        0xAA29
  60.  
  61. // * ****************************************************************************** *
  62.  
  63. //    Internal data storage
  64. typedef struct globalGammas {
  65.     short size, dataOffset;
  66.     GammaTblHandle saved, hacked;
  67.     GDHandle theGDevice;
  68.     struct globalGammas **next;
  69.     } globalGammas, *globalGammasPtr, **globalGammasHdl;
  70.     
  71. // * ****************************************************************************** *
  72. // * ****************************************************************************** *
  73. // Function Prototypes
  74.  
  75. Boolean IsGammaAvailable(void);
  76. Boolean IsOneGammaAvailable(GDHandle theGDevice);
  77.  
  78. //    These routines help you determine whether you can use the Gamma Table Utils
  79. //        on the current machine. The first checks all attached monitors, and the 
  80. //        second just checks the indicated monitor. Each returns TRUE if you can 
  81. //        use the functions, or FALSE if you can't. • Note: Before calling any other
  82. //        Gamma Table function below, use this function to see if you are allowed.
  83.  
  84. // * ****************************************************************************** *
  85.  
  86. OSErr SetupGammaTools(void);
  87. OSErr DisposeGammaTools(void);
  88.  
  89. //    These routines must bracket any calls to the Gamma Table functions, perhaps
  90. //        at the head and tail of your main(). The first sets up the data structures
  91. //        necessary to save and restore the state of your monitors. The second
  92. //        disposes of all the internal data structures, but does not reset the
  93. //        monitors to their original states. Both return the error code if some
  94. //        part failed. 
  95.  
  96. // * ****************************************************************************** *
  97.  
  98. OSErr DoGammaFade(short percent);
  99. OSErr DoOneGammaFade(GDHandle theGDevice, short percent);
  100.  
  101. //    Use the first function to Fade each of your monitors to some percentage of their
  102. //        initial brightness (100 = bright, 0 = dim). Repeatedly call this to ramp your
  103. //        monitors up or down. The second function performs the same function, but only
  104. //        for the specified monitor. Both return any applicable error codes.
  105. //    Be sure to set up the necessary save-state data structures before you start by
  106. //        calling the compatibility and initialization functions. 
  107.  
  108. // * ****************************************************************************** *
  109.  
  110. OSErr GetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  111. OSErr SetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  112.  
  113. //    These routines are low-level interfaces to the device drivers for the monitors.
  114. //        Use them at your own risk.
  115.  
  116.  
  117. #endif
  118.